<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<html>
<head>
    <meta charset="UTF-8">
    <title>分类详情</title>
    <link rel="stylesheet" href="style/First_Page.css"/>
    <link rel="stylesheet" href="style/classify.css"/>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="js/First_Page.js"></script>
    <script type="text/javascript">
        function getQueryVariable(variable)
        {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return decodeURI(pair[1]);}
            }
            return(false);
        }
        window.onload = function(){
            var a ="${sessionScope.login}";
            if(a=="1"){
                document.getElementById("login").style.display="none";
                document.getElementById("avatar").style.display="inline";
                document.getElementById("buy_car").style.display="inline";
                document.getElementById("car_image").style.display="inline";
                document.getElementById("exit").style.display="inline";
            }
            else{
                document.getElementById("login").style.display="inline";
                document.getElementById("avatar").style.display="none";
                document.getElementById("buy_car").style.display="none";
                document.getElementById("car_image").style.display="none";
                document.getElementById("exit").style.display="none";
            }
            var category=getQueryVariable("category");
            $.ajax({
                type:'GET',
                async:true,
                contentType:'text/json,charset=utf-8',
                dataType:'json',
                url:'/data/book' ,//接口
                data:{"category":category,'method':'category'},
                success:function (data) {
                    if(data.result==1)//与返回值比较，判断
                    {
                        var info=JSON.parse(data.books);
                        document.getElementById("classify_title_box").innerHTML="<p id=\"classify_title\"><b>读了么书籍标签："+category+"</b></p>";
                        for(var i=0;i<data.books.length;i++){
                            var tmp = document.createElement('li');

                            tmp.innerHTML = "<img src=\""+info[i].cover+"\" style=\"width：120px;height:150px;padding:15px;float: left;\">\n" +
                                "                <p class=\"book_name\">书名：<a href=\"http://localhost:8080/data/book?shopId="+info[i].shopId+"&bookId="+info[i].bookId+"&method=bookId\">"+info[i].bookName+"</a></p>\n" +
                                "                <p class=\"book_author\">作者："+info[i].author+"</p>\n" +
                                "                <p class=\"book_publicDate\">发行日期："+info[i].publishDate+"</p>\n" +
                                "                <p class=\"book_synopsis\">书籍概要："+info[i].synopsis+"</p>";
                            // tmp.innerHTML = "<a href=\"http://localhost:8080/duleme/data/book?shopId="+data.books[i].shopId+"&bookId="+data.books[i].bookId+"&method=bookId\" class=\"floor_goods_img\"><img src=\"image/book5.jpg\" class=\"img_style\"></a>\n" +
                            //     "<a id=\"floor_goods_tit\">"+info[i].bookName+"</a>\n" +
                            //     "<a id=\"floor_goods_txt\">余量：data.books.remain本</a>\n" +
                            //     "<a id=\"floor_goods_sold\">已售出：data.books.sell本</a>\n" +
                            //     "<a id=\"floor_goods_price\">data.books.price元</a>";
                            document.getElementById('book_box').appendChild(tmp);
                        }
                    }else{
                        alert('失败！')
                    }
                }
            });
        };
    </script>
</head>
<body>
<div id="main_head_box">
    <div class="head_box">
        <div id="head_wrap">
            <div id="head_right">
                <div id="head_landing">
                    <a id="login" class="head_nav_a" href="Login.html" style="display: inline;">登陆/注册</a>
                    <a href="Self_Information.jsp"><img src="${sessionScope.user.avatar}" id="avatar" style="display: none;height:30px;width:30px;border-radius: 45px;margin-right:50px;margin-top: 5px;"></a>
                    <a id="exit" style="display: none;float:right;margin-left:15px;" href="First_Page.jsp" onclick="login2exit()">注销</a>
                    <img src="image/buy_car.jpg" style="display:none;height:30px;width:30px;border-radius: 90px" id="car_image">
                    <a id="buy_car" class="head_nav_a" style="display: block;float:right;margin-left:5px;" href="Buy_Car.jsp">购物车</a>
                </div>
            </div>
        </div>
    </div>
    <div id="menu_wrap">
        <p id="menu_logo">读了么 <i>DuLeMe.com</i></p>
        <div id="find_wrap">
            <div id="find_bar">
                <input type="text" id="find_input">
            </div>
            <div id="find_but" onclick="search_method()"><a>GO</a></div>
        </div>
    </div>
</div>
<div id="classify">
    <div id="classify_title_box">

    </div>
    <div id="classify_main">
        <ul id="book_box">
<%--            <li>--%>
<%--                <img src="image/book1.jpg" style="padding:15px;float: left;">--%>
<%--                <p class="book_name">书名：<a href="">活着</a></p>--%>
<%--                <p class="book_author">作者：余华</p>--%>
<%--                <p class="book_publicDate">发行日期：2017-10-1</p>--%>
<%--                <p class="book_synopsis">书籍概要：《活着(新版)》讲述了农村人福贵悲惨的人生遭遇。福贵本是个阔少爷，可他嗜赌如命，终于赌光了家业，一贫如洗。他的父亲被他活活气死，母亲则在穷困中患了重病，福贵...</p>--%>
<%--            </li>--%>
<%--            <li>--%>
<%--                <img src="image/book2.jpg" style="padding:15px;float: left;">--%>
<%--                <p class="book_name">书名：<a href="">活着</a></p>--%>
<%--                <p class="book_author">作者：余华</p>--%>
<%--                <p class="book_publicDate">发行日期：2017-10-1</p>--%>
<%--                <p class="book_synopsis">书籍概要：《活着(新版)》讲述了农村人福贵悲惨的人生遭遇。福贵本是个阔少爷，可他嗜赌如命，终于赌光了家业，一贫如洗。他的父亲被他活活气死，母亲则在穷困中患了重病，福贵...</p>--%>
<%--            </li>--%>
            <div style="clear:both;"></div>
        </ul>
    </div>
</div>
<div id="foot_box">
    <div id="foot_wrap">
        <div class="foot_top">
            <ul>
                <li><a href="Self_Information.jsp">个人信息设置</a></li>
                <li class="font_top_i">|</li>
                <li><a href="First_Page.jsp">返回首页</a></li>
                <li class="font_top_i">|</li>
                <li>用户购物指南</li>
                <li class="font_top_i">|</li>
                <li><a href="user_Agreement.html">用户协议须知</a></li>
            </ul>
        </div>
        <div class="foot_bottom">
            <span> <a href="">返回顶部</a></span>
        </div>
    </div>
</div>
</body>
</html>
